import request from '@/utils/request'

/** -------------------计费规则相关请求函数-------------------- */
/**
 * 查看计费规则列表
 *
 * @param { page, pageSize } params
 *
 * @returns {Promise}
 */
export function getRuleListAPI(params) {
  return request({
    url: '/parking/rule/list',
    method: 'get',
    params
  })
}

/**
 * 添加计费规则
 *
 * @param { ruleNumber, ruleName, freeDuration, chargeCeiling, chargeType, durationTime, durationPrice, durationType, turnPrice, partitionFrameTime, partitionFramePrice, partitionIncreaseTime, partitionIncreasePrice } data
 *
 * @returns {Promise}
 */
export function addRuleAPI(data) {
  return request({
    url: '/parking/rule',
    method: 'post',
    data
  })
}

/**
 * 编辑计费规则
 *
 * @param { id, ruleNumber, ruleName, freeDuration, chargeCeiling, chargeType, durationTime, durationPrice, durationType, turnPrice, partitionFrameTime, partitionFramePrice, partitionIncreaseTime, partitionIncreasePrice } data
 *
 * @returns {Promise}
 */
export function editRuleAPI(data) {
  return request({
    url: '/parking/rule',
    method: 'put',
    data
  })
}

/**
 * 删除计费规则
 *
 * @param { String } id
 *
 * @returns {Promise}
 */
export function deleteRuleAPI(id) {
  return request({
    url: `/parking/rule/${id}`,
    method: 'delete'
  })
}

/**
 * 查看计费规则详情
 *
 * @param { String } id
 *
 * @returns {Promise}
 */
export function getRuleDetailsAPI(id) {
  return request({
    url: `/parking/rule/${id}`,
    method: 'get'
  })
}

/**
 * 获取计费规则下拉列表
 *
 * @returns {Promise}
 */
export function getRuleSelectListAPI() {
  return request({
    url: '/parking/rule/dropList',
    method: 'get'
  })
}
